-->

NEB 2079 computer science solution

 


Sub.Code: 4281'A'

NEB-GRADE XII 2079 (2022)

Computer Science

New Course

(For regular students)

Candidates are required to give their answers in their own words as far as practicable. The figures in the margin indicate full marks.

Time: 2 hrs.

Full Marks: 50

Attempt all the questions.

Group 'A'

Rewrite the correct options of each questions in your answer sheet. 9x1=9 

1. Which of the following SQL statement is used to DELETE rows from a database table?

A) DELETE B) REMOVE C) DROP D) CLEAR

2. A field that is used to uniquely called:

A) Primary Key     B)Entity C) Relationship D) Constraints


3. What does "MAC" stands

A) Mandatory Access Control B) Media Access Control    C) Micro Access Control  D) Media Access Certificate


4. What is the correct syntax for referring to an external JavaScript script?

 A) <script src="myscript.js"></script> B) <script href="myscript.js"></script> 

C) <js href="myscript.js"></js> D) <js src="myscript.js"></js>

5. Which of the following is the correct way of defining a variable in PHP?

A) $variable name = value; B) $variable_name = value; 

C) $variable_name= = value  D) $variable name as value;


6.

What is the output of C program? 

void main()

{

 int b=25;

//b memory location=1234;

int *p; p=&b;

 printf("%d %d", &b, p);}

A) 25 25 B) 1234 1234 C) 25  1234 D) 1234 25




7. Which feature of OOP illustrates the code reusability?

A) Polymorphism B) Abstraction c) Encapsulation D) Inheritance


8. Which of following is the discovering requirement from a user in the

requirement collection process?

A) Feasibility study B) Requirement Elicitation

C) Requirement Specification D) Requirement validation

9. What devices are detecting and responding to changes in an

environment that are embedded in smart phones and an integral part of the Internet of Things (IoT)?

A) Wi-Fi B) Barcode

C) RFID D) Sensors



Group 'B'(5x5=25)



Short answer questions

10. Differentiate the centralized and distributed database system.

OR

What are the purposes of normalization?Give an example of 2NF.

11. Write a program to find the factorial of any number using  Javascript.

Or

How do you fetch data from a database in PHP and display it in form? Describe.

12. Compare the OOPs and procedural programing language.

13. What are the major activities performed to design the software? Describe.

14 Explain the popular five-application areas of AI.


Group 'C'  (8x2=16)

Long answer questions

15. Compare the star and ring topology with pros and cons. Which of data communication cable is more appropriate to design the local area network? Describe.[5+3]

16. What is structure? Write a program to input roll, name and age of 5 students and display them properly using structure. [2+6]

OR

Write a C program to enter ID, employee_name, and post of the employee and store them in a data file named "emp.txt". Display each record on the screen in an appropriate format.

-0-





Solutions

1. Which of the following SQL statement is used to DELETE rows from a database table?

A) DELETE B) REMOVE C) DROP D) CLEAR

Ans:-

 A)DELETE


2. A field that is used to uniquely called:

A) Primary Key     B)Entity C) Relationship D) Constraints

Ans:-

 A)Primary Key 


3. What does "MAC" stands

A) Mandatory Access Control B) Media Access Control    C) Micro Access Control  D) Media Access Certificate

Ans:-

 B)Media Access Control



4. What is the correct syntax for referring to an external JavaScript script?

 A) <script src="myscript.js"></script> B) <script href="myscript.js"></script> 

C) <js href="myscript.js"></js> D) <js src="myscript.js"></js>

Ans:-

A)<script src="myscript.js"></script>


5. Which of the following is the correct way of defining a variable in PHP?

A) $variable name = value; B) $variable_name = value; 

C) $variable_name= = value  D) $variable name as value;

Ans:-

B)$variable_name = value; 



6.What is the output of a C program? 

void main()

{

 int b=25;

//b memory location=1234;

int *p; p=&b;

 printf("%d %d", &b, p);}

A) 25 25 B) 1234 1234 C) 25  1234 D) 1234 25

Ans:-

B)1234 1234


7. Which feature of OOP illustrates the code reusability?

A) Polymorphism B) Abstraction c) Encapsulation D) Inheritance

Ans:-

D)Inheritance


8. Which of following is the discovering requirement from a user in the requirement collection process?

A) Feasibility study B) Requirement Elicitation

C) Requirement Specification D) Requirement validation

Ans:-

B)Requirement Elicitation




9. What devices are detecting and responding to changes in an environment that are embedded in smart phones and an integral part of the Internet of Things (IoT)?

A) Wi-Fi B) Barcode

C) RFID D) Sensors

Ans:-

D) Sensors





Group 'B'(5x5=25)



Short answer questions

10. Differentiate the centralized and distributed database system.

Ans: The differences between centralized and distributed database systems are given below.


Basis of Comparison

Centralized database

Distributed database

Definition

It is a database that is stored, located as well as maintained at a single location only.

It is a database that consists of multiple databases which are connected with each other and are spread across different physical locations.

Access time

The data access time in the case of multiple users is more in a centralized database.

The data access time in the case of multiple users is less in a distributed database.

Management of data

The management, modification, and backup of this database are easier as the entire data is present at the same location.

The management, modification, and backup of this database are very difficult as it is spread across different physical locations.

View

This database provides a uniform and complete view to the user.

Since it is spread across different locations thus it is difficult to provide a uniform view to the user.

Data Consistency

This database has more data consistency in comparison to distributed database.

This database may have some data replications thus data consistency is less.

Failure

The users cannot access the database in case of database failure occurs.

In a distributed database, if one database fails users have access to other databases.



OR

What are the purposes of normalization?Give an example of 2NF.

Ans:-

Normalization:-

Normalization is the process of structuring and handling the relationship between data to minimize redundancy in the relational table and avoid the unnecessary anomalies properties from the database like insertion, update and delete. It helps to divide large database tables into smaller tables and make a relationship between them. It can remove redundant data and ease to add, manipulate or delete table fields.

Purpose of normalization:-

We can summarize the purpose of normalization as given below.

  • To correct duplicate data and database anomalies.

  • To avoid creating and updating any unwanted data connections and dependencies.

  • To prevent unwanted deletions of data.

  • To optimize storage space.

  • To reduce the delay and complexity of checking databases when new types of data need to be introduced.

  • To facilitate the access and interpretation of data to users and applications that make use of the databases.

2NF:-

The data is said to be in second normalized form If,

1.It is in First normal form

2.All Non-key attributes are fully functionally dependent on the primary key.

Example:

Let us consider following table which is in first normal form:

Employee No

Department No

Employee Name

Department

1

101

Amit

OBIEE

2

102

Divya

COGNOS

3

101

Rama

OBIEE

 

In above example we can see that department .Here We will see that there is composite key as{ Employee No,Department No}.Employee No is dependent on Employee Name and Department is dependent on Department No.We can split the above table into 2 different tables:

Table 1:Employee_NO table

Employee No

Department No

Employee Name

1

101

Amit

2

102

Divya

3

101

Rama

Table 2:Department table

Department No

Department

101

OBIEE

102

COGNOS

 

Now we have simplified the table into a second normal form where each entity of table is functionally dependent on the primary key.


11. Write a program to find the factorial of any number using  Javascript.

Ans:-

<!DOCTYPE html>

<html>

<head>

<title></title>

</head>

<body>

<script>

var i;

var factorial=1;

var n;

n=prompt("enter a number");

for(i=1;i<=n;i++)

{

factorial=factorial*i;

}

document.write("the factorial value is",factorial);

</script>

</body>

</html>


Or

How do you fetch data from a database in PHP and display it in form? Describe.

Ans:-

To understand the code we use in PHP to fetch data and print in form, we are going to assume the following table and records.


Let the table be student(st_id,st_grade) in our database named ‘student’. Let’s suppose this table contains some records as given here.

student

st_id

st_grade

1

12

2

12


In the real scenario, these records are stored in a database i.e. table. Now we have to fetch them and display them in text boxes(form).

For this we will use the following PHP and HTML codes.

<?php

    $connect=mysqli_connect("localhost","root","","student") or die("Connection failed");

?>

<html>

    <head>

        <title>

            display data from database

        </title>

    </head>

    <body>

<table>

<tr>

<th> student id</th><th>student grade</th>

</tr>

       <form  method="post">

        <?php

        $query = " select * from student";

        $result = mysqli_query($connect, $query);

        while ($row = mysqli_fetch_array($result)) 

{

        ?>

          <tr>

               <td>id</td> <td> <input type="text" value="<?php echo $row['st_id'];?>">

         </tr>    <br><br>

         <tr>

             <td>grade</td><td><input type="text" value="<?php  echo $row['st_grade'];  ?>">

        </tr>

            <br><br>

        <?php

        }

        ?>

    </form>

</table>

    </body>

</html>

12. Compare the OOPs and procedural programing language.

Ans:-

With the help of the following paragraph, we can compare and know between OOP and procedural programming language.

OOP(Object Oriented Programming):-

The major motivating factor in the invention of object oriented is to remove some of the flaws encountered in the procedural oriented approach. Object oriented programming uses concept of “Object” and treats data as a critical element in the program development and does not allow it to flow freely around the system. It ties data more closely to the functions that operate on it, and protects it from accidental modifications from outside functions.

Some characteristics (features) of Object Oriented Programming are :-

1) Emphasis is on data rather than procedures or algorithms.

2) Programs are divided into what are known as objects.

3) Data structures are designed such that characterize the objects.

4) Functions that operate on the data are tied together in the data structure.

5) Data is hidden and cannot be accessed by external functions.

6) Objects may communicate with each other through functions.

7) New data and functions can be easily added whenever necessary.

8) Follows bottom-up approach in program design.

Procedural Oriented Language:-

 Procedure oriented programming basically consists of writing a list of instructions(or actions) for the computer to follow, and organizing these instructions into groups known as functions. While we concentrate on the development , very little attention is given to the data that are being used by various functions.

            Diagrammatically we can show POP as 

 

Some characteristics (features) of Procedure Oriented Programming are :-

1) Emphasis is on doing things(algorithms).

2) Large programs are divided into smaller programs known as functions.

3) Most of the functions share global data.

4) Data more openly around the system from function to function.

5) Functions transform data from one form to another.

6) Employs a top-down approach in program design.


13. What are the major activities performed to design the software? Describe.

Ans:-

We can understand the major steps as given below to design software.

Let’s talk briefly.

 1)Problem definition:-The first step is problem definition(study). The intent is to identify the problem, determine its cause, and outline a strategy for solving it. It defines what ,when, who and how the project will be carried out. 

2) System analysis:-

Once the problems are identified, it is time to analyze the type of software that could answer the problems encountered. System analysis will take a look at possible software. The goal of a system analysis is to know the properties and functions of software that would answer the concerns solicited from intended users.

3)Systems Design: In this phase we start design of proposed new system.It describes desired features and operations in detail, including screen layouts, business rules, process diagrams, pseudo code and other documentation.

4)System development (Coding):

After designing the new system, the whole system is required to be converted into computer understanding language. Coding the new system into a computer programming language does this. It is an important stage where the defined procedures are transformed into control specifications by the help of a computer language. This is also called the programming phase in which the programmer converts the program specifications into computer instructions, which we refer as programs.

5. Testing:-

                            Before actually implementing the new system into operations, a test run of the system is done removing all the bugs, if any. It is an important phase of a successful system. After codifying the whole programs of the system, a test plan should be developed and run on a given set of test data. The output of the test run should match the expected results.

6.Implementation

After having the user acceptance of the new system developed, the implementation phase begins. Implementation is the stage of a project during which theory is turned into practice. During this phase, all the programs of the system are loaded onto the user's computer.

7.Maintenance:-Maintenance is necessary to eliminate errors in the system during its working life and to tune the system to any variations in its working environment. It has been seen that there are always some errors found in the system that must be noted and corrected. It also means the review of the system from time to time.

 

 

 


14 Explain the popular five-application areas of AI.

Ans:-

Following are major five application areas of AI.LEt’s know about them in detail.

1.Game playing

You can buy machines that can play master level chess for a few hundred dollars. There is some AI in them, but they play well against people mainly through brute force computation--looking at hundreds of thousands of positions. To beat a world champion by brute force and known reliable heuristics requires being able to look at 200 million positions per second.

2.speech recognition

In the 1990s, computer speech recognition reached a practical level for limited purposes. Thus United Airlines has replaced its keyboard tree for flight information by a system using speech recognition of flight numbers and city names. It is quite convenient. On the the other hand, while it is possible to instruct some computers using speech, most users have gone back to the keyboard and the mouse as still more convenient.

3. understanding natural language

Just getting a sequence of words into a computer is not enough. Parsing sentences is not enough either. The computer has to be provided with an understanding of the domain the text is about, and this is presently possible only for very limited domains.

4.computer vision

The world is composed of three-dimensional objects, but the inputs to the human eye and computers' TV cameras are two dimensional. Some useful programs can work solely in two dimensions, but full computer vision requires partial three-dimensional information that is not just a set of two-dimensional views. At present there are only limited ways of representing three-dimensional information directly, and they are not as good as what humans evidently use.

5.Expert systems

In artificial intelligence, an expert system is a computer system emulating the decision-making ability of a human expert. Expert systems are designed to solve complex problems by reasoning through bodies of knowledge, represented mainly as if–then rules.

Example:

  • MYCIN: It was one of the earliest backward chaining expert systems that was designed to find the bacteria causing infections like bacteraemia and meningitis. It was also used for the recommendation of antibiotics and the diagnosis of blood clotting diseases.

 



Group 'C'  (8x2=16)

Long answer questions

15. Compare the star and ring topology with pros and cons. Which data communication cable is more appropriate to design the local area network? Describe.[5+3]

Ans:-

Star topology:-

A star topology is designed with each node (file server, workstations, and peripherals) connected directly to a central network hub, switch, or concentrator (See fig.).Data on a star network passes through the hub, switch, or concentrator before continuing to its destination. The hub, switch, or concentrator manages and controls all functions of the network.It also acts as a repeater for the data flow. This configuration is common with twisted pair cable; however, it can also be used with coaxial cable or fiber optic cable.

 

 

                Fig. Star topology

Advantages of a Star Topology

  • Easy to install and wire.

  • No disruptions to the network when connecting or removing devices.

  • Easy to detect faults and to remove parts.

Disadvantages of a Star Topology

  • Requires more cable length than a linear topology.

  • If the hub, switch, or concentrator fails, nodes attached are disabled.

 

Ring topology:-

A ring topology is a network configuration where device connections create a circular data path. Each networked device is connected to two others, like points on a circle. Together, devices in a ring topology are referred to as a ring network.

In a ring network, packets of data travel from one device to the next until they reach their destination. Most ring topologies allow packets to travel only in one direction, called a unidirectional ring network. Others permit data to move in either direction, called bidirectional.

Advantages of a ring topology

  • All data flows in one direction, reducing the chance of packet collisions.

  • A network server is not needed to control network connectivity between each workstation.

  • Data can transfer between workstations at high speeds.

  • Additional workstations can be added without impacting performance of the network.

Disadvantages of a ring topology

  • All data being transferred over the network must pass through each workstation on the network, which can make it slower than a star topology.

  • The entire network will be impacted if one workstation shuts down.

  • The hardware needed to connect each workstation to the network is more expensive than Ethernet cards and hubs/switches.

Second part:-

In network communications, a transmission medium is a physical connection or an interface between the transmitter and the receiver. There are two major categories of transmission media, namely guided and wireless (or unguided). Let us take a walk through the types of transmission media as shown below.

Twisted Pair Cable

Twisted pair cables have been around for a long time. They were mainly invented for voice transmissions. Twisted pair is a widely used medium in networking because it's lighter, cheaper, more flexible, easy to install, and provides greater speeds than coaxial cables. So in my view twisted pair should be used for local area network.There are two types of twisted pair cables: the unshielded twisted pair (UTP) and the shielded twisted pair (STP). Let's take a closer look at each of them.

The unshielded twisted pair cable has 4 pairs of copper wires that are present inside a plastic sheath. These wires are twisted to protect them from interference. The only protection available for a UTP cable is a plastic sheath that is thin in size.

 

UTP

Advantages of Unshielded Twisted Pair Cable

  • Installation is easy

  • Flexible

  • Cheap

  • It has high speed capacity,

  • 100 meter limit

  • Higher grades of UTP are used in LAN technologies like Ethernet.

It consists of two insulating copper wires (1mm thick). The wires are twisted together in a helical form to reduce electrical interference from similar pairs.



16. What is structure? Write a program to input roll, name and age of 5 students and display them properly using structure. [2+6]

Ans:-

Structure:-

Structure is a user defined data type available in C that allows to combine data items of different kinds.

Structures are used to represent a record. Suppose we want to keep track of your books in a library. we might want to track the following attributes about each book −

  • Title

  • Author

  • Subject

  • Book ID

For this, structure is helpful.

Features:-

  1. We can copy items of one structure to another using = operator.

  2. We can use structure in nested form.

  3. We can pass the entire structure to a function.

  4. We can create an array for a given structure.

Syntax:

structure tag name

{

Data type member 1;

Data type member2;

} variable;


Example: 

struct book

{

Char b_name[100];

Char b_authro[100];

float b_price;

}v;


Second part:-

/* program to input roll, name and age of 5 students and display them properly using structure

*/

#include <stdio.h>

struct emp

{

    int roll;

    char name[100];

    int age;

}var[5];

int main()

{

    int i;

    printf("enter roll,name and age of students\n");

    for(i=0;i<=4;i++)

    {

        scanf("%d",&var[i].roll);

        scanf("%s",var[i].name);

        scanf("%d",&var[i].age);      

    }

    printf(" roll,name and age are:\n");

    for(i=0;i<=19;i++)

    {

        printf("roll=%d,name=%s,age=%d\n",var[i].roll,var[i].name,var[i].age);    

    }

    return 0;

}



OR

Write a C program to enter ID, employee_name, and post of the employee and store them in a data file named "emp.txt". Display each record on the screen in an appropriate format.

Ans:-

/*C program to enter ID, employee_name, and post of the employee and  store them in a data file named "emp.txt".Display each record on the screen in an appropriate format.

*/

#include <stdio.h>

#include<conio.h>

struct employee                          

{

    int employee_id;

    char employee_name[50];

    char employee_post[100];

    

}var;                                    

int main()

{

FILE *k;                                  

char choice;                        

k=fopen("emp.txt","w");             

do

{

printf("\n enter employee id\n");

scanf("%d",&var.employee_id);

printf("enter  employee name\n");  

scanf("%s",var.employee_name);

printf("enter employee post\n");

scanf("%s",var.employee_post);

fprintf(k,"%d %s %s\n",var.employee_id,var.employee_name,var.employee_post);

printf("want to continue (y/n):=\n");

choice=getche();                     

}while(choice!='n');        

printf("\n writing process completed successfully\n");

fclose(k);                                              

printf("-----------------------\n");

printf("reading data\n");             

k=fopen("emp.txt","r");               


while((fscanf(k,"%d%s%s",&var.employee_id,var.employee_name,var.employee_post))!=EOF)

{

printf("employee id=%d,employee name=%s,employee post=%s\n",var.employee_id,var.employee_name,var.employee_post);

}

fclose(k);                           

return 0;

}


-0-



=============================================================================

Find the solution of question on youtube:

Facebook:-


Instagram:

Tiktok:


No comments:

Post a Comment